<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - test/impl/debug.ipp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/impl</a> - debug.ipp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">202</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">28.2 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">57</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2006-2008.
<span class="lineNum">       2 </span>                : //  Use, modification, and distribution are subject to the
<span class="lineNum">       3 </span>                : //  Boost Software License, Version 1.0. (See accompanying file
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : debug interfaces implementation
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_DEBUG_API_IPP_112006GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_DEBUG_API_IPP_112006GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/detail/config.hpp&gt;
<span class="lineNum">      20 </span>                : #include &lt;boost/test/detail/workaround.hpp&gt;
<span class="lineNum">      21 </span>                : #include &lt;boost/test/detail/global_typedef.hpp&gt;
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : #include &lt;boost/test/debug.hpp&gt;
<span class="lineNum">      24 </span>                : #include &lt;boost/test/debug_config.hpp&gt;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : // Implementation in windows
<span class="lineNum">      27 </span>                : #if defined(_WIN32) &amp;&amp; !defined(UNDER_CE) &amp;&amp; !defined(BOOST_DISABLE_WIN32) // ******* WIN32
<span class="lineNum">      28 </span>                : 
<span class="lineNum">      29 </span>                : #  define BOOST_WIN32_BASED_DEBUG
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : // SYSTEM API
<span class="lineNum">      32 </span>                : #  include &lt;windows.h&gt;
<span class="lineNum">      33 </span>                : #  include &lt;winreg.h&gt;
<span class="lineNum">      34 </span>                : #  include &lt;cstdio&gt;
<span class="lineNum">      35 </span>                : #  include &lt;cstring&gt;
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : #  if !defined(NDEBUG) &amp;&amp; defined(_MSC_VER)
<span class="lineNum">      38 </span>                : #    define BOOST_MS_CRT_BASED_DEBUG
<span class="lineNum">      39 </span>                : #    include &lt;crtdbg.h&gt;
<span class="lineNum">      40 </span>                : #  endif
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : #  if BOOST_WORKAROUND( BOOST_MSVC, &lt;1300)
<span class="lineNum">      44 </span>                : #    define snprintf _snprintf
<span class="lineNum">      45 </span>                : #  endif
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : #  ifdef BOOST_NO_STDC_NAMESPACE
<span class="lineNum">      48 </span>                : namespace std { using ::memset; using ::sprintf; }
<span class="lineNum">      49 </span>                : #  endif
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span>                : #elif defined(unix) || defined(__unix) // ********************* UNIX
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                : #  define BOOST_UNIX_BASED_DEBUG
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                : // Boost.Test
<span class="lineNum">      56 </span>                : #include &lt;boost/test/utils/class_properties.hpp&gt;
<span class="lineNum">      57 </span>                : #include &lt;boost/test/utils/algorithm.hpp&gt;
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                : // STL
<span class="lineNum">      60 </span>                : #include &lt;cstring&gt;  // std::memcpy
<span class="lineNum">      61 </span>                : #include &lt;map&gt;
<span class="lineNum">      62 </span>                : #include &lt;cstdio&gt;
<span class="lineNum">      63 </span>                : #include &lt;stdarg.h&gt; // !! ?? cstdarg
<span class="lineNum">      64 </span>                : 
<span class="lineNum">      65 </span>                : // SYSTEM API
<span class="lineNum">      66 </span>                : #  include &lt;unistd.h&gt;
<span class="lineNum">      67 </span>                : #  include &lt;signal.h&gt;
<span class="lineNum">      68 </span>                : #  include &lt;fcntl.h&gt;
<span class="lineNum">      69 </span>                : 
<span class="lineNum">      70 </span>                : #  include &lt;sys/types.h&gt;
<span class="lineNum">      71 </span>                : #  include &lt;sys/stat.h&gt;
<span class="lineNum">      72 </span>                : #  include &lt;sys/wait.h&gt;
<span class="lineNum">      73 </span>                : #  include &lt;sys/time.h&gt;
<span class="lineNum">      74 </span>                : #  include &lt;stdio.h&gt;
<span class="lineNum">      75 </span>                : #  include &lt;stdlib.h&gt;
<span class="lineNum">      76 </span>                : 
<span class="lineNum">      77 </span>                : #  if defined(sun) || defined(__sun)
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span>                : #    define BOOST_SUN_BASED_DEBUG
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span>                : #    ifndef BOOST_TEST_DBG_LIST
<span class="lineNum">      82 </span>                : #      define BOOST_TEST_DBG_LIST dbx;gdb
<span class="lineNum">      83 </span>                : #    endif
<span class="lineNum">      84 </span>                : 
<span class="lineNum">      85 </span>                : #    define BOOST_TEST_CNL_DBG  dbx
<span class="lineNum">      86 </span>                : #    define BOOST_TEST_GUI_DBG  dbx-ddd
<span class="lineNum">      87 </span>                : 
<span class="lineNum">      88 </span>                : #    include &lt;procfs.h&gt;
<span class="lineNum">      89 </span>                : 
<span class="lineNum">      90 </span>                : #  elif defined(linux) || defined(__linux)
<span class="lineNum">      91 </span>                : 
<span class="lineNum">      92 </span>                : #    define BOOST_LINUX_BASED_DEBUG
<span class="lineNum">      93 </span>                : 
<span class="lineNum">      94 </span>                : #    include &lt;sys/ptrace.h&gt;
<span class="lineNum">      95 </span>                : 
<span class="lineNum">      96 </span>                : #    ifndef BOOST_TEST_STAT_LINE_MAX
<span class="lineNum">      97 </span>                : #      define BOOST_TEST_STAT_LINE_MAX 500
<span class="lineNum">      98 </span>                : #    endif
<span class="lineNum">      99 </span>                : 
<span class="lineNum">     100 </span>                : #    ifndef BOOST_TEST_DBG_LIST
<span class="lineNum">     101 </span>                : #      define BOOST_TEST_DBG_LIST gdb
<span class="lineNum">     102 </span>                : #    endif
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span>                : #    define BOOST_TEST_CNL_DBG  gdb
<span class="lineNum">     105 </span>                : #    define BOOST_TEST_GUI_DBG  gdb-xterm
<span class="lineNum">     106 </span>                : 
<span class="lineNum">     107 </span>                : #  endif
<span class="lineNum">     108 </span>                : 
<span class="lineNum">     109 </span>                : #endif
<span class="lineNum">     110 </span>                : 
<span class="lineNum">     111 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                : //____________________________________________________________________________//
<span class="lineNum">     114 </span>                : 
<span class="lineNum">     115 </span>                : namespace boost {
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span>                : namespace debug {
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span>                : using unit_test::const_string;
<span class="lineNum">     120 </span>                : 
<span class="lineNum">     121 </span>                : // ************************************************************************** //
<span class="lineNum">     122 </span>                : // **************                debug::info_t                 ************** //
<span class="lineNum">     123 </span>                : // ************************************************************************** //
<span class="lineNum">     124 </span>                : 
<span class="lineNum">     125 </span>                : namespace {
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span>                : #if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span>                : template&lt;typename T&gt;
<span class="lineNum">     130 </span>                : inline void
<span class="lineNum">     131 </span>                : dyn_symbol( T&amp; res, char const* module_name, char const* symbol_name )
<span class="lineNum">     132 </span>                : {
<span class="lineNum">     133 </span>                :     HMODULE m = ::GetModuleHandleA( module_name );
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                :     if( !m )
<span class="lineNum">     136 </span>                :         m = ::LoadLibraryA( module_name );
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span>                :     res = reinterpret_cast&lt;T&gt;( ::GetProcAddress( m, symbol_name ) );
<span class="lineNum">     139 </span>                : }
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span>                : //____________________________________________________________________________//
<span class="lineNum">     142 </span>                : 
<span class="lineNum">     143 </span>                : static struct info_t {
<span class="lineNum">     144 </span>                :     typedef BOOL (WINAPI* IsDebuggerPresentT)();
<span class="lineNum">     145 </span>                :     typedef LONG (WINAPI* RegQueryValueExT)( HKEY, char const* /*LPTSTR*/, LPDWORD, LPDWORD, LPBYTE, LPDWORD );
<span class="lineNum">     146 </span>                :     typedef LONG (WINAPI* RegOpenKeyT)( HKEY, char const* /*LPCTSTR*/, PHKEY );
<span class="lineNum">     147 </span>                :     typedef LONG (WINAPI* RegCloseKeyT)( HKEY );
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span>                :     info_t();
<span class="lineNum">     150 </span>                : 
<span class="lineNum">     151 </span>                :     IsDebuggerPresentT  m_is_debugger_present;
<span class="lineNum">     152 </span>                :     RegOpenKeyT         m_reg_open_key;
<span class="lineNum">     153 </span>                :     RegQueryValueExT    m_reg_query_value;
<span class="lineNum">     154 </span>                :     RegCloseKeyT        m_reg_close_key;
<span class="lineNum">     155 </span>                : 
<span class="lineNum">     156 </span>                : } s_info;
<span class="lineNum">     157 </span>                : 
<span class="lineNum">     158 </span>                : //____________________________________________________________________________//
<span class="lineNum">     159 </span>                : 
<span class="lineNum">     160 </span>                : info_t::info_t()
<span class="lineNum">     161 </span>                : {
<span class="lineNum">     162 </span>                :     dyn_symbol( m_is_debugger_present, &quot;kernel32&quot;, &quot;IsDebuggerPresent&quot; );
<span class="lineNum">     163 </span>                :     dyn_symbol( m_reg_open_key, &quot;advapi32&quot;, &quot;RegOpenKeyA&quot; );
<span class="lineNum">     164 </span>                :     dyn_symbol( m_reg_query_value, &quot;advapi32&quot;, &quot;RegQueryValueExA&quot; );
<span class="lineNum">     165 </span>                :     dyn_symbol( m_reg_close_key, &quot;advapi32&quot;, &quot;RegCloseKey&quot; );
<span class="lineNum">     166 </span>                : }
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                : //____________________________________________________________________________//
<span class="lineNum">     169 </span>                : 
<span class="lineNum">     170 </span>                : #elif defined(BOOST_UNIX_BASED_DEBUG)
<span class="lineNum">     171 </span>                : 
<span class="lineNum">     172 </span>                : // ************************************************************************** //
<span class="lineNum">     173 </span>                : // **************                   fd_holder                  ************** //
<span class="lineNum">     174 </span>                : // ************************************************************************** //
<span class="lineNum">     175 </span>                : 
<span class="lineNum">     176 </span>                : struct fd_holder {
<span class="lineNum">     177 </span><span class="lineCov">             65 :     explicit fd_holder( int fd ) : m_fd( fd ) {}</span>
<span class="lineNum">     178 </span><span class="lineCov">             65 :     ~fd_holder()</span>
<span class="lineNum">     179 </span>                :     {
<span class="lineNum">     180 </span><span class="lineCov">             65 :         if( m_fd != -1 )</span>
<span class="lineNum">     181 </span><span class="lineCov">             65 :             ::close( m_fd );</span>
<span class="lineNum">     182 </span><span class="lineCov">             65 :     }</span>
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span><span class="lineCov">            130 :     operator int() { return m_fd; }</span>
<span class="lineNum">     185 </span>                : 
<span class="lineNum">     186 </span>                : private:
<span class="lineNum">     187 </span>                :     // Data members
<span class="lineNum">     188 </span>                :     int m_fd;
<span class="lineNum">     189 </span>                : };
<span class="lineNum">     190 </span>                : 
<span class="lineNum">     191 </span>                : 
<span class="lineNum">     192 </span>                : // ************************************************************************** //
<span class="lineNum">     193 </span>                : // **************                 process_info                 ************** //
<span class="lineNum">     194 </span>                : // ************************************************************************** //
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : struct process_info {
<span class="lineNum">     197 </span>                :     // Constructor
<span class="lineNum">     198 </span>                :     explicit        process_info( int pid );
<span class="lineNum">     199 </span>                : 
<span class="lineNum">     200 </span>                :     // access methods
<span class="lineNum">     201 </span><span class="lineCov">             65 :     int             parent_pid() const  { return m_parent_pid; }</span>
<span class="lineNum">     202 </span><span class="lineCov">             65 :     const_string    binary_name() const { return m_binary_name; }</span>
<span class="lineNum">     203 </span><span class="lineNoCov">              0 :     const_string    binary_path() const { return m_binary_path; }</span>
<span class="lineNum">     204 </span>                : 
<span class="lineNum">     205 </span>                : private:
<span class="lineNum">     206 </span>                :     // Data members
<span class="lineNum">     207 </span>                :     int             m_parent_pid;
<span class="lineNum">     208 </span>                :     const_string    m_binary_name;
<span class="lineNum">     209 </span>                :     const_string    m_binary_path;
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span>                : #if defined(BOOST_SUN_BASED_DEBUG)
<span class="lineNum">     212 </span>                :     struct psinfo   m_psi;
<span class="lineNum">     213 </span>                : #elif defined(BOOST_LINUX_BASED_DEBUG)
<span class="lineNum">     214 </span>                :     char            m_stat_line[BOOST_TEST_STAT_LINE_MAX+1];
<span class="lineNum">     215 </span>                : #endif
<span class="lineNum">     216 </span>                :     char            m_binary_path_buff[500+1]; // !! ??
<span class="lineNum">     217 </span>                : };
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span>                : //____________________________________________________________________________//
<span class="lineNum">     220 </span>                : 
<span class="lineNum">     221 </span><span class="lineCov">             65 : process_info::process_info( int pid )</span>
<span class="lineNum">     222 </span><span class="lineCov">             65 : : m_parent_pid( 0 )</span>
<span class="lineNum">     223 </span>                : {
<span class="lineNum">     224 </span>                : #if defined(BOOST_SUN_BASED_DEBUG)
<span class="lineNum">     225 </span>                :     char fname_buff[30];
<span class="lineNum">     226 </span>                : 
<span class="lineNum">     227 </span>                :     ::snprintf( fname_buff, sizeof(fname_buff), &quot;/proc/%d/psinfo&quot;, pid );
<span class="lineNum">     228 </span>                : 
<span class="lineNum">     229 </span>                :     fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) );
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                :     if( psinfo_fd == -1 )
<span class="lineNum">     232 </span>                :         return;
<span class="lineNum">     233 </span>                : 
<span class="lineNum">     234 </span>                :     if( ::read( psinfo_fd, &amp;m_psi, sizeof(m_psi) ) == -1 )
<span class="lineNum">     235 </span>                :         return;
<span class="lineNum">     236 </span>                : 
<span class="lineNum">     237 </span>                :     m_parent_pid = m_psi.pr_ppid;
<span class="lineNum">     238 </span>                : 
<span class="lineNum">     239 </span>                :     m_binary_name.assign( m_psi.pr_fname );
<span class="lineNum">     240 </span>                : 
<span class="lineNum">     241 </span>                :     //-------------------------- //
<span class="lineNum">     242 </span>                :     
<span class="lineNum">     243 </span>                :     ::snprintf( fname_buff, sizeof(fname_buff), &quot;/proc/%d/as&quot;, pid );
<span class="lineNum">     244 </span>                : 
<span class="lineNum">     245 </span>                :     fd_holder as_fd( ::open( fname_buff, O_RDONLY ) );
<span class="lineNum">     246 </span>                :     uintptr_t   binary_name_pos;
<span class="lineNum">     247 </span>                :   
<span class="lineNum">     248 </span>                :     // !! ?? could we avoid reading whole m_binary_path_buff?
<span class="lineNum">     249 </span>                :     if( as_fd == -1 ||
<span class="lineNum">     250 </span>                :         ::lseek( as_fd, m_psi.pr_argv, SEEK_SET ) == -1 ||
<span class="lineNum">     251 </span>                :         ::read ( as_fd, &amp;binary_name_pos, sizeof(binary_name_pos) ) == -1 ||
<span class="lineNum">     252 </span>                :         ::lseek( as_fd, binary_name_pos, SEEK_SET ) == -1 ||
<span class="lineNum">     253 </span>                :         ::read ( as_fd, m_binary_path_buff, sizeof(m_binary_path_buff) ) == -1 )
<span class="lineNum">     254 </span>                :         return;
<span class="lineNum">     255 </span>                :         
<span class="lineNum">     256 </span>                :     m_binary_path.assign( m_binary_path_buff );
<span class="lineNum">     257 </span>                :         
<span class="lineNum">     258 </span>                : #elif defined(BOOST_LINUX_BASED_DEBUG)
<span class="lineNum">     259 </span>                :     char fname_buff[30];
<span class="lineNum">     260 </span>                : 
<span class="lineNum">     261 </span><span class="lineCov">             65 :     ::snprintf( fname_buff, sizeof(fname_buff), &quot;/proc/%d/stat&quot;, pid );</span>
<span class="lineNum">     262 </span>                : 
<span class="lineNum">     263 </span><span class="lineCov">             65 :     fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) );</span>
<span class="lineNum">     264 </span>                : 
<span class="lineNum">     265 </span><span class="lineCov">             65 :     if( psinfo_fd == -1 )</span>
<span class="lineNum">     266 </span>                :         return;
<span class="lineNum">     267 </span>                : 
<span class="lineNum">     268 </span><span class="lineCov">             65 :     ssize_t num_read = ::read( psinfo_fd, m_stat_line, sizeof(m_stat_line)-1 );</span>
<span class="lineNum">     269 </span><span class="lineCov">             65 :     if( num_read == -1 )</span>
<span class="lineNum">     270 </span>                :         return;
<span class="lineNum">     271 </span>                : 
<span class="lineNum">     272 </span><span class="lineCov">             65 :     m_stat_line[num_read] = 0;</span>
<span class="lineNum">     273 </span>                : 
<span class="lineNum">     274 </span><span class="lineCov">             65 :     char const* name_beg = m_stat_line;</span>
<span class="lineNum">     275 </span><span class="lineCov">            416 :     while( *name_beg &amp;&amp; *name_beg != '(' )</span>
<span class="lineNum">     276 </span><span class="lineCov">            286 :         ++name_beg;</span>
<span class="lineNum">     277 </span>                : 
<span class="lineNum">     278 </span><span class="lineCov">             65 :     char const* name_end = name_beg+1;</span>
<span class="lineNum">     279 </span><span class="lineCov">            601 :     while( *name_end &amp;&amp; *name_end != ')' )</span>
<span class="lineNum">     280 </span><span class="lineCov">            471 :         ++name_end;</span>
<span class="lineNum">     281 </span>                : 
<span class="lineNum">     282 </span><span class="lineCov">             65 :     std::sscanf( name_end+1, &quot;%*s%d&quot;, &amp;m_parent_pid );</span>
<span class="lineNum">     283 </span>                : 
<span class="lineNum">     284 </span><span class="lineCov">             65 :     m_binary_name.assign( name_beg+1, name_end );</span>
<span class="lineNum">     285 </span>                : 
<span class="lineNum">     286 </span><span class="lineCov">             65 :     ::snprintf( fname_buff, sizeof(fname_buff), &quot;/proc/%d/exe&quot;, pid );</span>
<span class="lineNum">     287 </span><span class="lineCov">             65 :     num_read = ::readlink( fname_buff, m_binary_path_buff, sizeof(m_binary_path_buff)-1 );</span>
<span class="lineNum">     288 </span>                : 
<span class="lineNum">     289 </span><span class="lineCov">             65 :     if( num_read == -1 )</span>
<span class="lineNum">     290 </span>                :         return;
<span class="lineNum">     291 </span>                : 
<span class="lineNum">     292 </span><span class="lineCov">             52 :     m_binary_path_buff[num_read] = 0;</span>
<span class="lineNum">     293 </span><span class="lineCov">             52 :     m_binary_path.assign( m_binary_path_buff, num_read );</span>
<span class="lineNum">     294 </span>                : #endif
<span class="lineNum">     295 </span>                : }
<span class="lineNum">     296 </span>                : 
<span class="lineNum">     297 </span>                : //____________________________________________________________________________//
<span class="lineNum">     298 </span>                : 
<span class="lineNum">     299 </span>                : // ************************************************************************** //
<span class="lineNum">     300 </span>                : // **************             prepare_window_title             ************** //
<span class="lineNum">     301 </span>                : // ************************************************************************** //
<span class="lineNum">     302 </span>                : 
<span class="lineNum">     303 </span>                : static char*
<span class="lineNum">     304 </span><span class="lineNoCov">              0 : prepare_window_title( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     305 </span>                : {
<span class="lineNum">     306 </span>                :     typedef unit_test::const_string str_t;
<span class="lineNum">     307 </span>                : 
<span class="lineNum">     308 </span>                :     static char title_str[50];
<span class="lineNum">     309 </span>                : 
<span class="lineNum">     310 </span><span class="lineNoCov">              0 :     str_t path_sep( &quot;\\/&quot; );</span>
<span class="lineNum">     311 </span>                : 
<span class="lineNum">     312 </span>                :     str_t::iterator  it = unit_test::find_last_of( dsi.binary_path.begin(), dsi.binary_path.end(),
<span class="lineNum">     313 </span><span class="lineNoCov">              0 :                                                    path_sep.begin(), path_sep.end() );</span>
<span class="lineNum">     314 </span>                : 
<span class="lineNum">     315 </span><span class="lineNoCov">              0 :     if( it == dsi.binary_path.end() )</span>
<span class="lineNum">     316 </span><span class="lineNoCov">              0 :         it = dsi.binary_path.begin();</span>
<span class="lineNum">     317 </span>                :     else
<span class="lineNum">     318 </span><span class="lineNoCov">              0 :         ++it;</span>
<span class="lineNum">     319 </span>                : 
<span class="lineNum">     320 </span><span class="lineNoCov">              0 :     ::snprintf( title_str, sizeof(title_str), &quot;%*s %ld&quot;, (int)(dsi.binary_path.end()-it), it, dsi.pid );</span>
<span class="lineNum">     321 </span>                : 
<span class="lineNum">     322 </span><span class="lineNoCov">              0 :     return title_str;</span>
<span class="lineNum">     323 </span>                : }
<span class="lineNum">     324 </span>                : 
<span class="lineNum">     325 </span>                : //____________________________________________________________________________//
<span class="lineNum">     326 </span>                : 
<span class="lineNum">     327 </span>                : // ************************************************************************** //
<span class="lineNum">     328 </span>                : // **************                  save_execlp                 ************** //
<span class="lineNum">     329 </span>                : // ************************************************************************** //
<span class="lineNum">     330 </span>                : 
<span class="lineNum">     331 </span>                : typedef unit_test::basic_cstring&lt;char&gt; mbuffer;
<span class="lineNum">     332 </span>                : 
<span class="lineNum">     333 </span>                : inline char*
<span class="lineNum">     334 </span><span class="lineNoCov">              0 : copy_arg( mbuffer&amp; dest, const_string arg )</span>
<span class="lineNum">     335 </span>                : {
<span class="lineNum">     336 </span><span class="lineNoCov">              0 :     if( dest.size() &lt; arg.size()+1 )</span>
<span class="lineNum">     337 </span><span class="lineNoCov">              0 :         return 0;</span>
<span class="lineNum">     338 </span>                : 
<span class="lineNum">     339 </span><span class="lineNoCov">              0 :     char* res = dest.begin();</span>
<span class="lineNum">     340 </span>                : 
<span class="lineNum">     341 </span><span class="lineNoCov">              0 :     std::memcpy( res, arg.begin(), arg.size()+1 );</span>
<span class="lineNum">     342 </span>                : 
<span class="lineNum">     343 </span><span class="lineNoCov">              0 :     dest.trim_left( arg.size()+1 );</span>
<span class="lineNum">     344 </span>                : 
<span class="lineNum">     345 </span><span class="lineNoCov">              0 :     return res;</span>
<span class="lineNum">     346 </span>                : }
<span class="lineNum">     347 </span>                : 
<span class="lineNum">     348 </span>                : //____________________________________________________________________________//
<span class="lineNum">     349 </span>                : 
<span class="lineNum">     350 </span>                : bool
<span class="lineNum">     351 </span><span class="lineNoCov">              0 : safe_execlp( char const* file, ... )</span>
<span class="lineNum">     352 </span>                : {
<span class="lineNum">     353 </span>                :     static char* argv_buff[200];
<span class="lineNum">     354 </span>                : 
<span class="lineNum">     355 </span>                :     va_list     args;
<span class="lineNum">     356 </span>                :     char const* arg;
<span class="lineNum">     357 </span>                : 
<span class="lineNum">     358 </span>                :     // first calculate actual number of arguments
<span class="lineNum">     359 </span><span class="lineNoCov">              0 :     int         num_args = 2; // file name and 0 at least</span>
<span class="lineNum">     360 </span>                : 
<span class="lineNum">     361 </span><span class="lineNoCov">              0 :     va_start( args, file );</span>
<span class="lineNum">     362 </span><span class="lineNoCov">              0 :     while( !!(arg = va_arg( args, char const* )) )</span>
<span class="lineNum">     363 </span><span class="lineNoCov">              0 :         num_args++;</span>
<span class="lineNum">     364 </span><span class="lineNoCov">              0 :     va_end( args );</span>
<span class="lineNum">     365 </span>                : 
<span class="lineNum">     366 </span>                :     // reserve space for the argument pointers array
<span class="lineNum">     367 </span><span class="lineNoCov">              0 :     char**      argv_it  = argv_buff;</span>
<span class="lineNum">     368 </span><span class="lineNoCov">              0 :     mbuffer     work_buff( reinterpret_cast&lt;char*&gt;(argv_buff), sizeof(argv_buff) );</span>
<span class="lineNum">     369 </span><span class="lineNoCov">              0 :     work_buff.trim_left( num_args * sizeof(char*) );</span>
<span class="lineNum">     370 </span>                : 
<span class="lineNum">     371 </span>                :     // copy all the argument values into local storage
<span class="lineNum">     372 </span><span class="lineNoCov">              0 :     if( !(*argv_it++ = copy_arg( work_buff, file )) )</span>
<span class="lineNum">     373 </span><span class="lineNoCov">              0 :         return false;</span>
<span class="lineNum">     374 </span>                : 
<span class="lineNum">     375 </span><span class="lineNoCov">              0 :     printf( &quot;!! %s\n&quot;, file );</span>
<span class="lineNum">     376 </span>                : 
<span class="lineNum">     377 </span><span class="lineNoCov">              0 :     va_start( args, file );</span>
<span class="lineNum">     378 </span><span class="lineNoCov">              0 :     while( !!(arg = va_arg( args, char const* )) ) {</span>
<span class="lineNum">     379 </span><span class="lineNoCov">              0 :         printf( &quot;!! %s\n&quot;, arg );</span>
<span class="lineNum">     380 </span><span class="lineNoCov">              0 :         if( !(*argv_it++ = copy_arg( work_buff, arg )) )</span>
<span class="lineNum">     381 </span><span class="lineNoCov">              0 :             return false;</span>
<span class="lineNum">     382 </span>                :     }
<span class="lineNum">     383 </span><span class="lineNoCov">              0 :     va_end( args );</span>
<span class="lineNum">     384 </span>                : 
<span class="lineNum">     385 </span><span class="lineNoCov">              0 :     *argv_it = 0;</span>
<span class="lineNum">     386 </span>                : 
<span class="lineNum">     387 </span><span class="lineNoCov">              0 :     return ::execvp( file, argv_buff ) != -1;</span>
<span class="lineNum">     388 </span>                : }
<span class="lineNum">     389 </span>                : 
<span class="lineNum">     390 </span>                : //____________________________________________________________________________//
<span class="lineNum">     391 </span>                : 
<span class="lineNum">     392 </span>                : // ************************************************************************** //
<span class="lineNum">     393 </span>                : // **************            start_debugger_in_emacs           ************** //
<span class="lineNum">     394 </span>                : // ************************************************************************** //
<span class="lineNum">     395 </span>                : 
<span class="lineNum">     396 </span>                : static void
<span class="lineNum">     397 </span><span class="lineNoCov">              0 : start_debugger_in_emacs( dbg_startup_info const&amp; dsi, char const* emacs_name, char const* dbg_command )</span>
<span class="lineNum">     398 </span>                : {
<span class="lineNum">     399 </span><span class="lineNoCov">              0 :     char const* title = prepare_window_title( dsi );</span>
<span class="lineNum">     400 </span>                : 
<span class="lineNum">     401 </span><span class="lineNoCov">              0 :     if( !title )</span>
<span class="lineNum">     402 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     403 </span>                : 
<span class="lineNum">     404 </span>                :     dsi.display.is_empty()
<span class="lineNum">     405 </span>                :         ? safe_execlp( emacs_name, &quot;-title&quot;, title, &quot;--eval&quot;, dbg_command, 0 )
<span class="lineNum">     406 </span><span class="lineNoCov">              0 :         : safe_execlp( emacs_name, &quot;-title&quot;, title, &quot;-display&quot;, dsi.display.begin(), &quot;--eval&quot;, dbg_command, 0 );</span>
<span class="lineNum">     407 </span>                : }
<span class="lineNum">     408 </span>                : 
<span class="lineNum">     409 </span>                : //____________________________________________________________________________//
<span class="lineNum">     410 </span>                : 
<span class="lineNum">     411 </span>                : // ************************************************************************** //
<span class="lineNum">     412 </span>                : // **************                 gdb starters                 ************** //
<span class="lineNum">     413 </span>                : // ************************************************************************** //
<span class="lineNum">     414 </span>                : 
<span class="lineNum">     415 </span>                : static char const*
<span class="lineNum">     416 </span><span class="lineNoCov">              0 : prepare_gdb_cmnd_file( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     417 </span>                : {
<span class="lineNum">     418 </span>                :     // prepare pid value
<span class="lineNum">     419 </span>                :     char pid_buff[16];
<span class="lineNum">     420 </span><span class="lineNoCov">              0 :     ::snprintf( pid_buff, sizeof(pid_buff), &quot;%ld&quot;, dsi.pid );</span>
<span class="lineNum">     421 </span><span class="lineNoCov">              0 :     unit_test::const_string pid_str( pid_buff );</span>
<span class="lineNum">     422 </span>                : 
<span class="lineNum">     423 </span>                :     static char cmd_file_name[] = &quot;/tmp/btl_gdb_cmd_XXXXXX&quot;; // !! ??
<span class="lineNum">     424 </span>                : 
<span class="lineNum">     425 </span>                :     // prepare commands
<span class="lineNum">     426 </span><span class="lineNoCov">              0 :     fd_holder cmd_fd( ::mkstemp( cmd_file_name ) );</span>
<span class="lineNum">     427 </span>                : 
<span class="lineNum">     428 </span><span class="lineNoCov">              0 :     if( cmd_fd == -1 )</span>
<span class="lineNum">     429 </span><span class="lineNoCov">              0 :         return 0;</span>
<span class="lineNum">     430 </span>                : 
<span class="lineNum">     431 </span>                : #define WRITE_STR( str )  if( ::write( cmd_fd, str.begin(), str.size() ) == -1 ) return 0;
<span class="lineNum">     432 </span>                : #define WRITE_CSTR( str ) if( ::write( cmd_fd, str, sizeof( str )-1 ) == -1 ) return 0;
<span class="lineNum">     433 </span>                : 
<span class="lineNum">     434 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;file &quot; );</span>
<span class="lineNum">     435 </span><span class="lineNoCov">              0 :     WRITE_STR( dsi.binary_path );</span>
<span class="lineNum">     436 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\nattach &quot; );</span>
<span class="lineNum">     437 </span><span class="lineNoCov">              0 :     WRITE_STR( pid_str );</span>
<span class="lineNum">     438 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\nshell unlink &quot; );</span>
<span class="lineNum">     439 </span><span class="lineNoCov">              0 :     WRITE_STR( dsi.init_done_lock );</span>
<span class="lineNum">     440 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\ncont&quot; );</span>
<span class="lineNum">     441 </span><span class="lineNoCov">              0 :     if( dsi.break_or_continue )</span>
<span class="lineNum">     442 </span><span class="lineNoCov">              0 :         WRITE_CSTR( &quot;\nup 4&quot; );</span>
<span class="lineNum">     443 </span>                :             
<span class="lineNum">     444 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\necho \\n&quot; ); // !! ??</span>
<span class="lineNum">     445 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\nlist -&quot; );</span>
<span class="lineNum">     446 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\nlist&quot; );</span>
<span class="lineNum">     447 </span><span class="lineNoCov">              0 :     WRITE_CSTR( &quot;\nshell unlink &quot; );</span>
<span class="lineNum">     448 </span><span class="lineNoCov">              0 :     WRITE_CSTR( cmd_file_name );</span>
<span class="lineNum">     449 </span>                : 
<span class="lineNum">     450 </span><span class="lineNoCov">              0 :     return cmd_file_name;</span>
<span class="lineNum">     451 </span>                : }
<span class="lineNum">     452 </span>                : 
<span class="lineNum">     453 </span>                : //____________________________________________________________________________//
<span class="lineNum">     454 </span>                : 
<span class="lineNum">     455 </span>                : static void
<span class="lineNum">     456 </span><span class="lineNoCov">              0 : start_gdb_in_console( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     457 </span>                : {
<span class="lineNum">     458 </span><span class="lineNoCov">              0 :     char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi );</span>
<span class="lineNum">     459 </span>                : 
<span class="lineNum">     460 </span><span class="lineNoCov">              0 :     if( !cmnd_file_name )</span>
<span class="lineNum">     461 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     462 </span>                : 
<span class="lineNum">     463 </span><span class="lineNoCov">              0 :     safe_execlp( &quot;gdb&quot;, &quot;-q&quot;, &quot;-x&quot;, cmnd_file_name, 0 );</span>
<span class="lineNum">     464 </span>                : }
<span class="lineNum">     465 </span>                : 
<span class="lineNum">     466 </span>                : //____________________________________________________________________________//
<span class="lineNum">     467 </span>                : 
<span class="lineNum">     468 </span>                : static void
<span class="lineNum">     469 </span><span class="lineNoCov">              0 : start_gdb_in_xterm( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     470 </span>                : {
<span class="lineNum">     471 </span><span class="lineNoCov">              0 :     char const* title           = prepare_window_title( dsi );</span>
<span class="lineNum">     472 </span><span class="lineNoCov">              0 :     char const* cmnd_file_name  = prepare_gdb_cmnd_file( dsi );</span>
<span class="lineNum">     473 </span>                : 
<span class="lineNum">     474 </span><span class="lineNoCov">              0 :     if( !title || !cmnd_file_name )</span>
<span class="lineNum">     475 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     476 </span>                : 
<span class="lineNum">     477 </span>                :     safe_execlp( &quot;xterm&quot;, &quot;-T&quot;, title, &quot;-display&quot;, dsi.display.begin(),
<span class="lineNum">     478 </span>                :                     &quot;-bg&quot;, &quot;black&quot;, &quot;-fg&quot;, &quot;white&quot;, &quot;-geometry&quot;, &quot;88x30+10+10&quot;, &quot;-fn&quot;, &quot;9x15&quot;, &quot;-e&quot;,
<span class="lineNum">     479 </span><span class="lineNoCov">              0 :                  &quot;gdb&quot;, &quot;-q&quot;, &quot;-x&quot;, cmnd_file_name, 0 );</span>
<span class="lineNum">     480 </span>                : }
<span class="lineNum">     481 </span>                : 
<span class="lineNum">     482 </span>                : //____________________________________________________________________________//
<span class="lineNum">     483 </span>                : 
<span class="lineNum">     484 </span>                : static void
<span class="lineNum">     485 </span><span class="lineNoCov">              0 : start_gdb_in_emacs( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     486 </span>                : {
<span class="lineNum">     487 </span><span class="lineNoCov">              0 :     char const* cmnd_file_name  = prepare_gdb_cmnd_file( dsi );</span>
<span class="lineNum">     488 </span><span class="lineNoCov">              0 :     if( !cmnd_file_name )</span>
<span class="lineNum">     489 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     490 </span>                : 
<span class="lineNum">     491 </span>                :     char dbg_cmd_buff[500]; // !! ??
<span class="lineNum">     492 </span><span class="lineNoCov">              0 :     ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), &quot;(progn (gdb \&quot;gdb -q -x %s\&quot;))&quot;, cmnd_file_name );</span>
<span class="lineNum">     493 </span>                : 
<span class="lineNum">     494 </span><span class="lineNoCov">              0 :     start_debugger_in_emacs( dsi, &quot;emacs&quot;, dbg_cmd_buff );</span>
<span class="lineNum">     495 </span>                : }
<span class="lineNum">     496 </span>                : 
<span class="lineNum">     497 </span>                : //____________________________________________________________________________//
<span class="lineNum">     498 </span>                : 
<span class="lineNum">     499 </span>                : static void
<span class="lineNum">     500 </span><span class="lineNoCov">              0 : start_gdb_in_xemacs( dbg_startup_info const&amp; )</span>
<span class="lineNum">     501 </span>                : {
<span class="lineNum">     502 </span>                :     // !! ??
<span class="lineNum">     503 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     504 </span>                : 
<span class="lineNum">     505 </span>                : //____________________________________________________________________________//
<span class="lineNum">     506 </span>                : 
<span class="lineNum">     507 </span>                : // ************************************************************************** //
<span class="lineNum">     508 </span>                : // **************                 dbx starters                 ************** //
<span class="lineNum">     509 </span>                : // ************************************************************************** //
<span class="lineNum">     510 </span>                : 
<span class="lineNum">     511 </span>                : static char const*
<span class="lineNum">     512 </span><span class="lineNoCov">              0 : prepare_dbx_cmd_line( dbg_startup_info const&amp; dsi, bool list_source = true )</span>
<span class="lineNum">     513 </span>                : {
<span class="lineNum">     514 </span>                :     static char cmd_line_buff[500]; // !! ??
<span class="lineNum">     515 </span>                : 
<span class="lineNum">     516 </span>                :     ::snprintf( cmd_line_buff, sizeof(cmd_line_buff), &quot;unlink %s;cont;%s%s&quot;, 
<span class="lineNum">     517 </span>                :                    dsi.init_done_lock.begin(), 
<span class="lineNum">     518 </span>                :                    dsi.break_or_continue ? &quot;up 2;&quot;: &quot;&quot;, 
<span class="lineNum">     519 </span><span class="lineNoCov">              0 :                    list_source ? &quot;echo \&quot; \&quot;;list -w3;&quot; : &quot;&quot; );</span>
<span class="lineNum">     520 </span>                : 
<span class="lineNum">     521 </span><span class="lineNoCov">              0 :     return cmd_line_buff;</span>
<span class="lineNum">     522 </span>                : }
<span class="lineNum">     523 </span>                : 
<span class="lineNum">     524 </span>                : //____________________________________________________________________________//
<span class="lineNum">     525 </span>                : 
<span class="lineNum">     526 </span>                : static void
<span class="lineNum">     527 </span><span class="lineNoCov">              0 : start_dbx_in_console( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     528 </span>                : {
<span class="lineNum">     529 </span>                :     char pid_buff[16];
<span class="lineNum">     530 </span><span class="lineNoCov">              0 :     ::snprintf( pid_buff, sizeof(pid_buff), &quot;%ld&quot;, dsi.pid );</span>
<span class="lineNum">     531 </span>                : 
<span class="lineNum">     532 </span><span class="lineNoCov">              0 :     safe_execlp( &quot;dbx&quot;, &quot;-q&quot;, &quot;-c&quot;, prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 );</span>
<span class="lineNum">     533 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     534 </span>                : 
<span class="lineNum">     535 </span>                : //____________________________________________________________________________//
<span class="lineNum">     536 </span>                : 
<span class="lineNum">     537 </span>                : static void
<span class="lineNum">     538 </span><span class="lineNoCov">              0 : start_dbx_in_xterm( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     539 </span>                : {
<span class="lineNum">     540 </span><span class="lineNoCov">              0 :     char const* title = prepare_window_title( dsi );</span>
<span class="lineNum">     541 </span><span class="lineNoCov">              0 :     if( !title )</span>
<span class="lineNum">     542 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     543 </span>                : 
<span class="lineNum">     544 </span>                :     char pid_buff[16]; // !! ??
<span class="lineNum">     545 </span><span class="lineNoCov">              0 :     ::snprintf( pid_buff, sizeof(pid_buff), &quot;%ld&quot;, dsi.pid );</span>
<span class="lineNum">     546 </span>                :     
<span class="lineNum">     547 </span>                :     safe_execlp( &quot;xterm&quot;, &quot;-T&quot;, title, &quot;-display&quot;, dsi.display.begin(), 
<span class="lineNum">     548 </span>                :                     &quot;-bg&quot;, &quot;black&quot;, &quot;-fg&quot;, &quot;white&quot;, &quot;-geometry&quot;, &quot;88x30+10+10&quot;, &quot;-fn&quot;, &quot;9x15&quot;, &quot;-e&quot;,
<span class="lineNum">     549 </span><span class="lineNoCov">              0 :                  &quot;dbx&quot;, &quot;-q&quot;, &quot;-c&quot;, prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 );</span>
<span class="lineNum">     550 </span>                : }
<span class="lineNum">     551 </span>                : 
<span class="lineNum">     552 </span>                : //____________________________________________________________________________//
<span class="lineNum">     553 </span>                : 
<span class="lineNum">     554 </span>                : static void
<span class="lineNum">     555 </span><span class="lineNoCov">              0 : start_dbx_in_emacs( dbg_startup_info const&amp; /*dsi*/ )</span>
<span class="lineNum">     556 </span>                : {
<span class="lineNum">     557 </span>                : //    char dbg_cmd_buff[500]; // !! ??
<span class="lineNum">     558 </span>                : //
<span class="lineNum">     559 </span>                : //    ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), &quot;(progn (dbx \&quot;dbx -q -c cont %s %ld\&quot;))&quot;, dsi.binary_path.begin(), dsi.pid );
<span class="lineNum">     560 </span>                : 
<span class="lineNum">     561 </span>                : //    start_debugger_in_emacs( dsi, &quot;emacs&quot;, dbg_cmd_buff );
<span class="lineNum">     562 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     563 </span>                : 
<span class="lineNum">     564 </span>                : //____________________________________________________________________________//
<span class="lineNum">     565 </span>                : 
<span class="lineNum">     566 </span>                : static void
<span class="lineNum">     567 </span><span class="lineNoCov">              0 : start_dbx_in_xemacs( dbg_startup_info const&amp; )</span>
<span class="lineNum">     568 </span>                : {
<span class="lineNum">     569 </span>                :     // !! ??
<span class="lineNum">     570 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     571 </span>                : 
<span class="lineNum">     572 </span>                : //____________________________________________________________________________//
<span class="lineNum">     573 </span>                : 
<span class="lineNum">     574 </span>                : static void
<span class="lineNum">     575 </span><span class="lineNoCov">              0 : start_dbx_in_ddd( dbg_startup_info const&amp; dsi )</span>
<span class="lineNum">     576 </span>                : {
<span class="lineNum">     577 </span><span class="lineNoCov">              0 :     char const* title = prepare_window_title( dsi );</span>
<span class="lineNum">     578 </span><span class="lineNoCov">              0 :     if( !title )</span>
<span class="lineNum">     579 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     580 </span>                : 
<span class="lineNum">     581 </span>                :     char pid_buff[16]; // !! ??
<span class="lineNum">     582 </span><span class="lineNoCov">              0 :     ::snprintf( pid_buff, sizeof(pid_buff), &quot;%ld&quot;, dsi.pid );</span>
<span class="lineNum">     583 </span>                :     
<span class="lineNum">     584 </span>                :     safe_execlp( &quot;ddd&quot;, &quot;-display&quot;, dsi.display.begin(),
<span class="lineNum">     585 </span><span class="lineNoCov">              0 :                  &quot;--dbx&quot;, &quot;-q&quot;, &quot;-c&quot;, prepare_dbx_cmd_line( dsi, false ), dsi.binary_path.begin(), pid_buff, 0 );</span>
<span class="lineNum">     586 </span>                : }
<span class="lineNum">     587 </span>                : 
<span class="lineNum">     588 </span>                : //____________________________________________________________________________//
<span class="lineNum">     589 </span>                : 
<span class="lineNum">     590 </span>                : // ************************************************************************** //
<span class="lineNum">     591 </span>                : // **************                debug::info_t                 ************** //
<span class="lineNum">     592 </span>                : // ************************************************************************** //
<span class="lineNum">     593 </span>                : 
<span class="lineNum">     594 </span><span class="lineCov">              2 : static struct info_t {</span>
<span class="lineNum">     595 </span>                :     // Constructor
<span class="lineNum">     596 </span>                :     info_t();
<span class="lineNum">     597 </span>                : 
<span class="lineNum">     598 </span>                :     // Public properties
<span class="lineNum">     599 </span>                :     unit_test::readwrite_property&lt;std::string&gt;  p_dbg;
<span class="lineNum">     600 </span>                :     
<span class="lineNum">     601 </span>                :     // Data members
<span class="lineNum">     602 </span>                :     std::map&lt;std::string,dbg_starter&gt;           m_dbg_starter_reg;
<span class="lineNum">     603 </span><span class="lineCov">              2 : } s_info;</span>
<span class="lineNum">     604 </span>                : 
<span class="lineNum">     605 </span>                : //____________________________________________________________________________//
<span class="lineNum">     606 </span>                : 
<span class="lineNum">     607 </span><span class="lineCov">              2 : info_t::info_t()</span>
<span class="lineNum">     608 </span>                : {
<span class="lineNum">     609 </span>                :     p_dbg.value = ::getenv( &quot;DISPLAY&quot; )
<span class="lineNum">     610 </span>                :         ? std::string( BOOST_STRINGIZE( BOOST_TEST_GUI_DBG ) )
<span class="lineNum">     611 </span><span class="lineCov">              2 :         : std::string( BOOST_STRINGIZE( BOOST_TEST_CNL_DBG ) );</span>
<span class="lineNum">     612 </span>                :         
<span class="lineNum">     613 </span><span class="lineCov">              2 :     m_dbg_starter_reg[std::string(&quot;gdb&quot;)]           = &amp;start_gdb_in_console;</span>
<span class="lineNum">     614 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;gdb-emacs&quot;)]     = &amp;start_gdb_in_emacs;</span>
<span class="lineNum">     615 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;gdb-xterm&quot;)]     = &amp;start_gdb_in_xterm;</span>
<span class="lineNum">     616 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;gdb-xemacs&quot;)]    = &amp;start_gdb_in_xemacs;</span>
<span class="lineNum">     617 </span>                : 
<span class="lineNum">     618 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;dbx&quot;)]           = &amp;start_dbx_in_console;</span>
<span class="lineNum">     619 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;dbx-emacs&quot;)]     = &amp;start_dbx_in_emacs;</span>
<span class="lineNum">     620 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;dbx-xterm&quot;)]     = &amp;start_dbx_in_xterm;</span>
<span class="lineNum">     621 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;dbx-xemacs&quot;)]    = &amp;start_dbx_in_xemacs;</span>
<span class="lineNum">     622 </span><span class="lineCov">              4 :     m_dbg_starter_reg[std::string(&quot;dbx-ddd&quot;)]       = &amp;start_dbx_in_ddd;</span>
<span class="lineNum">     623 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     624 </span>                : 
<span class="lineNum">     625 </span>                : //____________________________________________________________________________//
<span class="lineNum">     626 </span>                : 
<span class="lineNum">     627 </span>                : #endif
<span class="lineNum">     628 </span>                : 
<span class="lineNum">     629 </span>                : } // local namespace
<span class="lineNum">     630 </span>                : 
<span class="lineNum">     631 </span>                : // ************************************************************************** //
<span class="lineNum">     632 </span>                : // **************  check if program is running under debugger  ************** //
<span class="lineNum">     633 </span>                : // ************************************************************************** //
<span class="lineNum">     634 </span>                : 
<span class="lineNum">     635 </span>                : bool
<span class="lineNum">     636 </span><span class="lineCov">             13 : under_debugger()</span>
<span class="lineNum">     637 </span>                : {
<span class="lineNum">     638 </span>                : #if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
<span class="lineNum">     639 </span>                : 
<span class="lineNum">     640 </span>                :     return !!s_info.m_is_debugger_present &amp;&amp; s_info.m_is_debugger_present();
<span class="lineNum">     641 </span>                : 
<span class="lineNum">     642 </span>                : #elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
<span class="lineNum">     643 </span>                : 
<span class="lineNum">     644 </span>                :     // !! ?? could/should we cache the result somehow?
<span class="lineNum">     645 </span><span class="lineCov">             13 :     const_string    dbg_list = BOOST_TEST_STRINGIZE( BOOST_TEST_DBG_LIST );</span>
<span class="lineNum">     646 </span>                : 
<span class="lineNum">     647 </span><span class="lineCov">             13 :     pid_t pid = ::getpid();</span>
<span class="lineNum">     648 </span>                : 
<span class="lineNum">     649 </span><span class="lineCov">             91 :     while( pid != 0 ) {</span>
<span class="lineNum">     650 </span><span class="lineCov">             65 :         process_info pi( pid );</span>
<span class="lineNum">     651 </span>                : 
<span class="lineNum">     652 </span>                :         // !! ?? should we use tokenizer here instead?
<span class="lineNum">     653 </span><span class="lineCov">             65 :         if( dbg_list.find( pi.binary_name() ) != const_string::npos )</span>
<span class="lineNum">     654 </span><span class="lineNoCov">              0 :             return true;</span>
<span class="lineNum">     655 </span>                : 
<span class="lineNum">     656 </span><span class="lineCov">             65 :         pid = pi.parent_pid();</span>
<span class="lineNum">     657 </span>                :     }
<span class="lineNum">     658 </span>                : 
<span class="lineNum">     659 </span><span class="lineCov">             13 :     return false;</span>
<span class="lineNum">     660 </span>                : 
<span class="lineNum">     661 </span>                : #else // ****************************************************** default
<span class="lineNum">     662 </span>                : 
<span class="lineNum">     663 </span>                :     return false;
<span class="lineNum">     664 </span>                : 
<span class="lineNum">     665 </span>                : #endif
<span class="lineNum">     666 </span>                : }
<span class="lineNum">     667 </span>                : 
<span class="lineNum">     668 </span>                : //____________________________________________________________________________//
<span class="lineNum">     669 </span>                : 
<span class="lineNum">     670 </span>                : // ************************************************************************** //
<span class="lineNum">     671 </span>                : // **************       cause program to break execution       ************** //
<span class="lineNum">     672 </span>                : // **************           in debugger at call point          ************** //
<span class="lineNum">     673 </span>                : // ************************************************************************** //
<span class="lineNum">     674 </span>                : 
<span class="lineNum">     675 </span>                : void
<span class="lineNum">     676 </span><span class="lineNoCov">              0 : debugger_break()</span>
<span class="lineNum">     677 </span>                : {
<span class="lineNum">     678 </span>                :     // !! ?? auto-start debugger?
<span class="lineNum">     679 </span>                : 
<span class="lineNum">     680 </span>                : #if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
<span class="lineNum">     681 </span>                : 
<span class="lineNum">     682 </span>                : #if BOOST_WORKAROUND(BOOST_MSVC, &gt;= 1300)                       ||  \
<span class="lineNum">     683 </span>                :     BOOST_WORKAROUND(__GNUC__, &gt;= 3) &amp;&amp; !defined(__MINGW32__)   ||  \
<span class="lineNum">     684 </span>                :     defined(__INTEL_COMPILER)
<span class="lineNum">     685 </span>                : #   define BOOST_DEBUG_BREAK    __debugbreak
<span class="lineNum">     686 </span>                : #else
<span class="lineNum">     687 </span>                : #   define BOOST_DEBUG_BREAK    DebugBreak
<span class="lineNum">     688 </span>                : #endif
<span class="lineNum">     689 </span>                : 
<span class="lineNum">     690 </span>                : #ifndef __MINGW32__
<span class="lineNum">     691 </span>                :     if( !under_debugger() ) {
<span class="lineNum">     692 </span>                :         __try {
<span class="lineNum">     693 </span>                :             __try {
<span class="lineNum">     694 </span>                :                 BOOST_DEBUG_BREAK();
<span class="lineNum">     695 </span>                :             }
<span class="lineNum">     696 </span>                :             __except( UnhandledExceptionFilter(GetExceptionInformation()) )
<span class="lineNum">     697 </span>                :             {
<span class="lineNum">     698 </span>                :                 // User opted to ignore the breakpoint
<span class="lineNum">     699 </span>                :                 return;
<span class="lineNum">     700 </span>                :             }
<span class="lineNum">     701 </span>                :         }
<span class="lineNum">     702 </span>                :         __except (EXCEPTION_EXECUTE_HANDLER)
<span class="lineNum">     703 </span>                :         {
<span class="lineNum">     704 </span>                :             // If we got here, the user has pushed Debug. Debugger is already attached to our process and we
<span class="lineNum">     705 </span>                :             // continue to let the another BOOST_DEBUG_BREAK to be called.
<span class="lineNum">     706 </span>                :         }
<span class="lineNum">     707 </span>                :     }
<span class="lineNum">     708 </span>                : #endif
<span class="lineNum">     709 </span>                : 
<span class="lineNum">     710 </span>                :     BOOST_DEBUG_BREAK();
<span class="lineNum">     711 </span>                : 
<span class="lineNum">     712 </span>                : #elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
<span class="lineNum">     713 </span>                : 
<span class="lineNum">     714 </span><span class="lineNoCov">              0 :     ::kill( ::getpid(), SIGTRAP );</span>
<span class="lineNum">     715 </span>                : 
<span class="lineNum">     716 </span>                : #else // ****************************************************** default
<span class="lineNum">     717 </span>                : 
<span class="lineNum">     718 </span>                : #endif
<span class="lineNum">     719 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     720 </span>                : 
<span class="lineNum">     721 </span>                : //____________________________________________________________________________//
<span class="lineNum">     722 </span>                : 
<span class="lineNum">     723 </span>                : // ************************************************************************** //
<span class="lineNum">     724 </span>                : // **************            console debugger setup            ************** //
<span class="lineNum">     725 </span>                : // ************************************************************************** //
<span class="lineNum">     726 </span>                : 
<span class="lineNum">     727 </span>                : #if defined(BOOST_UNIX_BASED_DEBUG) // ************************ UNIX
<span class="lineNum">     728 </span>                : 
<span class="lineNum">     729 </span>                : std::string
<span class="lineNum">     730 </span><span class="lineNoCov">              0 : set_debugger( unit_test::const_string dbg_id, dbg_starter s )</span>
<span class="lineNum">     731 </span>                : {
<span class="lineNum">     732 </span><span class="lineNoCov">              0 :     std::string old = s_info.p_dbg;</span>
<span class="lineNum">     733 </span>                : 
<span class="lineNum">     734 </span><span class="lineNoCov">              0 :     assign_op( s_info.p_dbg.value, dbg_id, 0 );</span>
<span class="lineNum">     735 </span>                : 
<span class="lineNum">     736 </span><span class="lineNoCov">              0 :     if( !!s )</span>
<span class="lineNum">     737 </span><span class="lineNoCov">              0 :         s_info.m_dbg_starter_reg[s_info.p_dbg] = s;</span>
<span class="lineNum">     738 </span>                : 
<span class="lineNum">     739 </span><span class="lineNoCov">              0 :     return old;</span>
<span class="lineNum">     740 </span>                : }
<span class="lineNum">     741 </span>                : 
<span class="lineNum">     742 </span>                : #else  // ***************************************************** default
<span class="lineNum">     743 </span>                : 
<span class="lineNum">     744 </span>                : std::string
<span class="lineNum">     745 </span>                : set_debugger( unit_test::const_string, dbg_starter )
<span class="lineNum">     746 </span>                : {
<span class="lineNum">     747 </span>                :     return std::string();
<span class="lineNum">     748 </span>                : }
<span class="lineNum">     749 </span>                : 
<span class="lineNum">     750 </span>                : #endif
<span class="lineNum">     751 </span>                : 
<span class="lineNum">     752 </span>                : //____________________________________________________________________________//
<span class="lineNum">     753 </span>                : 
<span class="lineNum">     754 </span>                : // ************************************************************************** //
<span class="lineNum">     755 </span>                : // **************    attach debugger to the current process    ************** //
<span class="lineNum">     756 </span>                : // ************************************************************************** //
<span class="lineNum">     757 </span>                : 
<span class="lineNum">     758 </span>                : bool
<span class="lineNum">     759 </span><span class="lineNoCov">              0 : attach_debugger( bool break_or_continue )</span>
<span class="lineNum">     760 </span>                : {
<span class="lineNum">     761 </span><span class="lineNoCov">              0 :     if( under_debugger() )</span>
<span class="lineNum">     762 </span><span class="lineNoCov">              0 :         return false;</span>
<span class="lineNum">     763 </span>                : 
<span class="lineNum">     764 </span>                : #if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
<span class="lineNum">     765 </span>                : 
<span class="lineNum">     766 </span>                :     const int MAX_CMD_LINE = 200;
<span class="lineNum">     767 </span>                : 
<span class="lineNum">     768 </span>                :     // *************************************************** //
<span class="lineNum">     769 </span>                :     // Debugger &quot;ready&quot; event
<span class="lineNum">     770 </span>                : 
<span class="lineNum">     771 </span>                :     SECURITY_ATTRIBUTES attr;
<span class="lineNum">     772 </span>                :     attr.nLength                = sizeof(attr);
<span class="lineNum">     773 </span>                :     attr.lpSecurityDescriptor   = NULL;
<span class="lineNum">     774 </span>                :     attr.bInheritHandle         = true;
<span class="lineNum">     775 </span>                : 
<span class="lineNum">     776 </span>                :     // manual resettable, initially non signaled, unnamed event,
<span class="lineNum">     777 </span>                :     // that will signal me that debugger initialization is done
<span class="lineNum">     778 </span>                :     HANDLE dbg_init_done_ev = ::CreateEvent(
<span class="lineNum">     779 </span>                :         &amp;attr,          // pointer to security attributes
<span class="lineNum">     780 </span>                :         true,           // flag for manual-reset event
<span class="lineNum">     781 </span>                :         false,          // flag for initial state
<span class="lineNum">     782 </span>                :         NULL            // pointer to event-object name
<span class="lineNum">     783 </span>                :     );
<span class="lineNum">     784 </span>                : 
<span class="lineNum">     785 </span>                :     if( !dbg_init_done_ev )
<span class="lineNum">     786 </span>                :         return false;
<span class="lineNum">     787 </span>                : 
<span class="lineNum">     788 </span>                :     // *************************************************** //
<span class="lineNum">     789 </span>                :     // Debugger command line format
<span class="lineNum">     790 </span>                : 
<span class="lineNum">     791 </span>                :     HKEY reg_key;
<span class="lineNum">     792 </span>                : 
<span class="lineNum">     793 </span>                :     if( !s_info.m_reg_open_key || (*s_info.m_reg_open_key)(
<span class="lineNum">     794 </span>                :             HKEY_LOCAL_MACHINE,                                         // handle of open key
<span class="lineNum">     795 </span>                :             &quot;Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug&quot;, // name of subkey to open
<span class="lineNum">     796 </span>                :             &amp;reg_key ) != ERROR_SUCCESS )                               // address of handle of open key
<span class="lineNum">     797 </span>                :         return false;
<span class="lineNum">     798 </span>                : 
<span class="lineNum">     799 </span>                :     char  format[MAX_CMD_LINE];
<span class="lineNum">     800 </span>                :     DWORD format_size = MAX_CMD_LINE;
<span class="lineNum">     801 </span>                :     DWORD type = REG_SZ;
<span class="lineNum">     802 </span>                : 
<span class="lineNum">     803 </span>                :     if( !s_info.m_reg_query_value || (*s_info.m_reg_query_value)(
<span class="lineNum">     804 </span>                :             reg_key,                            // handle of open key
<span class="lineNum">     805 </span>                :             &quot;Debugger&quot;,                         // name of subkey to query
<span class="lineNum">     806 </span>                :             0,                                  // reserved
<span class="lineNum">     807 </span>                :             &amp;type,                              // value type
<span class="lineNum">     808 </span>                :             (LPBYTE)format,                     // buffer for returned string
<span class="lineNum">     809 </span>                :             &amp;format_size ) != ERROR_SUCCESS )   // in: buffer size; out: actual size of returned string
<span class="lineNum">     810 </span>                :         return false;
<span class="lineNum">     811 </span>                : 
<span class="lineNum">     812 </span>                :     if( !s_info.m_reg_close_key || (*s_info.m_reg_close_key)( reg_key ) != ERROR_SUCCESS )
<span class="lineNum">     813 </span>                :         return false;
<span class="lineNum">     814 </span>                : 
<span class="lineNum">     815 </span>                :     // *************************************************** //
<span class="lineNum">     816 </span>                :     // Debugger command line
<span class="lineNum">     817 </span>                : 
<span class="lineNum">     818 </span>                :     char cmd_line[MAX_CMD_LINE];
<span class="lineNum">     819 </span>                :     std::sprintf( cmd_line, format, ::GetCurrentProcessId(), dbg_init_done_ev );
<span class="lineNum">     820 </span>                : 
<span class="lineNum">     821 </span>                :     // *************************************************** //
<span class="lineNum">     822 </span>                :     // Debugger window parameters
<span class="lineNum">     823 </span>                : 
<span class="lineNum">     824 </span>                :     STARTUPINFOA    startup_info;
<span class="lineNum">     825 </span>                :     std::memset( &amp;startup_info, 0, sizeof(startup_info) );
<span class="lineNum">     826 </span>                : 
<span class="lineNum">     827 </span>                :     startup_info.cb             = sizeof(startup_info);
<span class="lineNum">     828 </span>                :     startup_info.dwFlags        = STARTF_USESHOWWINDOW;
<span class="lineNum">     829 </span>                :     startup_info.wShowWindow    = SW_SHOWNORMAL;
<span class="lineNum">     830 </span>                : 
<span class="lineNum">     831 </span>                :     // debugger process s_info
<span class="lineNum">     832 </span>                :     PROCESS_INFORMATION debugger_info;
<span class="lineNum">     833 </span>                : 
<span class="lineNum">     834 </span>                :     bool created = !!::CreateProcessA(
<span class="lineNum">     835 </span>                :         NULL,           // pointer to name of executable module; NULL - use the one in command line
<span class="lineNum">     836 </span>                :         cmd_line,       // pointer to command line string
<span class="lineNum">     837 </span>                :         NULL,           // pointer to process security attributes; NULL - debugger's handle couldn't be inherited
<span class="lineNum">     838 </span>                :         NULL,           // pointer to thread security attributes; NULL - debugger's handle couldn't be inherited
<span class="lineNum">     839 </span>                :         true,           // debugger inherit opened handles
<span class="lineNum">     840 </span>                :         0,              // priority flags; 0 - normal priority
<span class="lineNum">     841 </span>                :         NULL,           // pointer to new environment block; NULL - use this process environment
<span class="lineNum">     842 </span>                :         NULL,           // pointer to current directory name; NULL - use this process correct directory
<span class="lineNum">     843 </span>                :         &amp;startup_info,  // pointer to STARTUPINFO that specifies main window appearance
<span class="lineNum">     844 </span>                :         &amp;debugger_info  // pointer to PROCESS_INFORMATION that will contain the new process identification
<span class="lineNum">     845 </span>                :     );
<span class="lineNum">     846 </span>                : 
<span class="lineNum">     847 </span>                :     if( created )
<span class="lineNum">     848 </span>                :         ::WaitForSingleObject( dbg_init_done_ev, INFINITE );
<span class="lineNum">     849 </span>                : 
<span class="lineNum">     850 </span>                :     ::CloseHandle( dbg_init_done_ev );
<span class="lineNum">     851 </span>                : 
<span class="lineNum">     852 </span>                :     if( !created )
<span class="lineNum">     853 </span>                :         return false;
<span class="lineNum">     854 </span>                : 
<span class="lineNum">     855 </span>                :     if( break_or_continue )
<span class="lineNum">     856 </span>                :         debugger_break();
<span class="lineNum">     857 </span>                : 
<span class="lineNum">     858 </span>                :     return true;
<span class="lineNum">     859 </span>                : 
<span class="lineNum">     860 </span>                : #elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
<span class="lineNum">     861 </span>                : 
<span class="lineNum">     862 </span><span class="lineNoCov">              0 :     char init_done_lock_fn[] = &quot;/tmp/btl_dbg_init_done_XXXXXX&quot;;</span>
<span class="lineNum">     863 </span><span class="lineNoCov">              0 :     fd_holder init_done_lock_fd( ::mkstemp( init_done_lock_fn ) );</span>
<span class="lineNum">     864 </span>                : 
<span class="lineNum">     865 </span><span class="lineNoCov">              0 :     if( init_done_lock_fd == -1 )</span>
<span class="lineNum">     866 </span><span class="lineNoCov">              0 :         return false;</span>
<span class="lineNum">     867 </span>                :     
<span class="lineNum">     868 </span><span class="lineNoCov">              0 :     pid_t child_pid = fork();</span>
<span class="lineNum">     869 </span>                : 
<span class="lineNum">     870 </span><span class="lineNoCov">              0 :     if( child_pid == -1 )</span>
<span class="lineNum">     871 </span><span class="lineNoCov">              0 :         return false;</span>
<span class="lineNum">     872 </span>                : 
<span class="lineNum">     873 </span><span class="lineNoCov">              0 :     if( child_pid != 0 ) { // parent process - here we will start the debugger</span>
<span class="lineNum">     874 </span><span class="lineNoCov">              0 :         dbg_startup_info dsi;</span>
<span class="lineNum">     875 </span>                :     
<span class="lineNum">     876 </span><span class="lineNoCov">              0 :         process_info pi( child_pid );</span>
<span class="lineNum">     877 </span><span class="lineNoCov">              0 :         if( pi.binary_path().is_empty() )</span>
<span class="lineNum">     878 </span><span class="lineNoCov">              0 :             ::exit( -1 );</span>
<span class="lineNum">     879 </span>                : 
<span class="lineNum">     880 </span><span class="lineNoCov">              0 :         dsi.pid                 = child_pid;</span>
<span class="lineNum">     881 </span><span class="lineNoCov">              0 :         dsi.break_or_continue   = break_or_continue;</span>
<span class="lineNum">     882 </span><span class="lineNoCov">              0 :         dsi.binary_path         = pi.binary_path();</span>
<span class="lineNum">     883 </span><span class="lineNoCov">              0 :         dsi.display             = ::getenv( &quot;DISPLAY&quot; );</span>
<span class="lineNum">     884 </span><span class="lineNoCov">              0 :         dsi.init_done_lock      = init_done_lock_fn;</span>
<span class="lineNum">     885 </span>                :         
<span class="lineNum">     886 </span><span class="lineNoCov">              0 :         dbg_starter starter = s_info.m_dbg_starter_reg[s_info.p_dbg];</span>
<span class="lineNum">     887 </span><span class="lineNoCov">              0 :         if( !!starter )</span>
<span class="lineNum">     888 </span><span class="lineNoCov">              0 :             starter( dsi );</span>
<span class="lineNum">     889 </span>                : 
<span class="lineNum">     890 </span><span class="lineNoCov">              0 :         ::perror( &quot;Boost.Test execution monitor failed to start a debugger:&quot; );</span>
<span class="lineNum">     891 </span>                : 
<span class="lineNum">     892 </span><span class="lineNoCov">              0 :         ::exit( -1 );</span>
<span class="lineNum">     893 </span>                :     }
<span class="lineNum">     894 </span>                : 
<span class="lineNum">     895 </span>                :     // child process - here we will continue our test module execution ; // !! ?? should it be vice versa
<span class="lineNum">     896 </span>                : 
<span class="lineNum">     897 </span><span class="lineNoCov">              0 :     while( ::access( init_done_lock_fn, F_OK ) == 0 ) {</span>
<span class="lineNum">     898 </span><span class="lineNoCov">              0 :         struct timeval to = { 0, 100 };</span>
<span class="lineNum">     899 </span>                : 
<span class="lineNum">     900 </span><span class="lineNoCov">              0 :         ::select( 0, 0, 0, 0, &amp;to );</span>
<span class="lineNum">     901 </span>                :     }
<span class="lineNum">     902 </span>                : 
<span class="lineNum">     903 </span>                : //    char dummy;
<span class="lineNum">     904 </span>                : //    while( ::read( init_done_lock_fd, &amp;dummy, sizeof(char) ) == 0 );
<span class="lineNum">     905 </span>                : 
<span class="lineNum">     906 </span><span class="lineNoCov">              0 :     if( break_or_continue )</span>
<span class="lineNum">     907 </span><span class="lineNoCov">              0 :         debugger_break();</span>
<span class="lineNum">     908 </span>                : 
<span class="lineNum">     909 </span><span class="lineNoCov">              0 :     return true;</span>
<span class="lineNum">     910 </span>                : 
<span class="lineNum">     911 </span>                : #else // ****************************************************** default
<span class="lineNum">     912 </span>                : 
<span class="lineNum">     913 </span>                :     return false;
<span class="lineNum">     914 </span>                : 
<span class="lineNum">     915 </span>                : #endif
<span class="lineNum">     916 </span>                : }
<span class="lineNum">     917 </span>                : 
<span class="lineNum">     918 </span>                : //____________________________________________________________________________//
<span class="lineNum">     919 </span>                : 
<span class="lineNum">     920 </span>                : // ************************************************************************** //
<span class="lineNum">     921 </span>                : // **************   switch on/off detect memory leaks feature  ************** //
<span class="lineNum">     922 </span>                : // ************************************************************************** //
<span class="lineNum">     923 </span>                : 
<span class="lineNum">     924 </span>                : void
<span class="lineNum">     925 </span><span class="lineCov">              2 : detect_memory_leaks( bool on_off )</span>
<span class="lineNum">     926 </span>                : {
<span class="lineNum">     927 </span><span class="lineCov">              2 :     unit_test::ut_detail::ignore_unused_variable_warning( on_off );</span>
<span class="lineNum">     928 </span>                : 
<span class="lineNum">     929 </span>                : #ifdef BOOST_MS_CRT_BASED_DEBUG
<span class="lineNum">     930 </span>                :     int flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
<span class="lineNum">     931 </span>                : 
<span class="lineNum">     932 </span>                :     if( !on_off )
<span class="lineNum">     933 </span>                :         flags &amp;= ~_CRTDBG_LEAK_CHECK_DF;
<span class="lineNum">     934 </span>                :     else  {
<span class="lineNum">     935 </span>                :         flags |= _CRTDBG_LEAK_CHECK_DF;
<span class="lineNum">     936 </span>                :         _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
<span class="lineNum">     937 </span>                :         _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
<span class="lineNum">     938 </span>                :     }
<span class="lineNum">     939 </span>                : 
<span class="lineNum">     940 </span>                :     _CrtSetDbgFlag ( flags );
<span class="lineNum">     941 </span>                : #endif // BOOST_MS_CRT_BASED_DEBUG
<span class="lineNum">     942 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     943 </span>                : 
<span class="lineNum">     944 </span>                : //____________________________________________________________________________//
<span class="lineNum">     945 </span>                : 
<span class="lineNum">     946 </span>                : // ************************************************************************** //
<span class="lineNum">     947 </span>                : // **************      cause program to break execution in     ************** //
<span class="lineNum">     948 </span>                : // **************     debugger at specific allocation point    ************** //
<span class="lineNum">     949 </span>                : // ************************************************************************** //
<span class="lineNum">     950 </span>                : 
<span class="lineNum">     951 </span>                : void
<span class="lineNum">     952 </span><span class="lineCov">              2 : break_memory_alloc( long mem_alloc_order_num )</span>
<span class="lineNum">     953 </span>                : {
<span class="lineNum">     954 </span><span class="lineCov">              2 :     unit_test::ut_detail::ignore_unused_variable_warning( mem_alloc_order_num );</span>
<span class="lineNum">     955 </span>                : 
<span class="lineNum">     956 </span>                : #ifdef BOOST_MS_CRT_BASED_DEBUG
<span class="lineNum">     957 </span>                :     _CrtSetBreakAlloc( mem_alloc_order_num );
<span class="lineNum">     958 </span>                : #endif // BOOST_MS_CRT_BASED_DEBUG
<span class="lineNum">     959 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     960 </span>                : 
<span class="lineNum">     961 </span>                : } // namespace debug
<span class="lineNum">     962 </span>                : 
<span class="lineNum">     963 </span>                : } // namespace boost
<span class="lineNum">     964 </span>                : 
<span class="lineNum">     965 </span>                : //____________________________________________________________________________//
<span class="lineNum">     966 </span>                : 
<span class="lineNum">     967 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     968 </span>                : 
<span class="lineNum">     969 </span>                : #endif // BOOST_TEST_DEBUG_API_IPP_112006GER
<span class="lineNum">     970 </span>                : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
